/**
 * @author : 乔磊磊
 * @ide    : WebStorm
 * @date   : 2025/2/23 星期日 18:44
 * @desc   :
 */
import {_decorator} from "cc"
import {EventComponent} from "../component/EventComponent"
import {logger} from "../log";
import {IUIViewParam} from "./IUIViewParam"

const {ccclass, property} = _decorator

@ccclass("UIViewBase")
export class UIViewBase extends EventComponent {
    protected _viewParam: IUIViewParam | undefined
    private _onViewColes: Function | undefined

    public setViewInfo(value: IUIViewParam, onClose: Function) {
        this._viewParam = value
        this._onViewColes = onClose
    }

    protected closeView() {
        logger.log("[close view]：", this._viewParam?.prefabPath)
        this.node.destroy()
    }

    protected onDestroy() {
        this._onViewColes && this._onViewColes()
    }
}
